	<script type="text/javascript">
<!--
function validateForm(){
	
if(document.getElementById('code').value==''){ 
	alert('<?php echo lang('required_field')?>');
	document.getElementById('code').select();
	return false;
}
else if(document.getElementById('first_name').value==''){ alert('<?php echo lang('required_field')?>');

document.getElementById('first_name').select();
return false;
}
else if(document.getElementById('lastname').value==''){ alert('<?php echo lang('required_field')?>');

document.getElementById('lastname').select();
return false;
}

if(document.getElementById('code').value.length<3){ 
	alert('<?php echo lang('minimum_length')?> 3');
	document.getElementById('code').select();
	return false;
}
else if(document.getElementById('first_name').value.length<3){
alert('<?php echo lang('minimum_length')?> 3');
document.getElementById('first_name').select();
return false;
}
else if(document.getElementById('lastname').value.length<3){ 
alert('<?php echo lang('minimum_length')?> 3');
document.getElementById('lastname').select();
return false;
}


//else document.customForm.submit();
return true
	
}
//-->
</script>
   <?php echo validation_errors(); ?>
	<?php
	if(isset($form_action) && !empty($form_action))
		$action = site_url()."/patient/".$form_action;
	else
		$action = site_url()."/patient/new_patient2";
	?>
	<form id="customForm" name="customForm" method="post" action="<?php echo $action?>">
		
		<input type="hidden" id="id" name="patient_form[id]" value="<?php if(isset($id)) echo $id?>" />
		
		
		<label><?php echo lang('general_code')?></label>
		<input type="text" id="code" name="patient_form[code]" value="<?php echo set_value('code'); if(isset($code)) echo $code?>" <?php  if(isset($code)) echo 'readonly'?> />
		
		<label><?php echo lang('general_1stname')?></label>
		<input type="text" id="first_name" name="patient_form[first_name]" value="<?php echo set_value('first_name'); if(isset($first_name)) echo $first_name?>" />
		
		<label><?php echo lang('general_lastname')?></label>
		<input type="text" id="lastname" name="patient_form[last_name]" value="<?php echo set_value('last_name'); if(isset($last_name)) echo $last_name?>" />
	
		<label><?php echo lang('form_label_email')?></label>
		<input type="text" id="email" name="patient_form[email]" value="<?php echo set_value('email'); if(isset($email)) echo $email?>" />
		
		<input type="submit" id="submit" name="submit" onClick="return validateForm();" value="<?php echo lang('form_label_save')?>" />
	</form>
